{% extends "./inc/base.html" %} {% block style %}
<!--<link rel="stylesheet" href="/static/admin/js/zTree/metroStyle/metroStyle.css" type="text/css">-->
<style>
    .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td{
        vertical-align:middle;
    }
</style>
 {% endblock%} {% block content %}
<section class="vbox">
    <section id="bjax-target">
        <section class="hbox stretch">
            <section>
                <section class="vbox">
                    <section class="scrollable wrapper">
                        <section class="panel panel-default">
                            <header class="panel-heading">
                                <!--<i data-title="" data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""><i class="fa fa-question-circle"></i></i>-->

                                {% if breadcrumb|length == 0%} [ {% if controller.get('position') %} <a href="/admin/article/ad" class="text-info">全部</a>{%else%}<strong>全部</strong>{%endif%}
                                {%for key ,val in config.setup.DOCUMENT_POSITION %} {%if controller.get('position') != key %}<a href="/admin/article/ad?position={{key}}"
                                class="text-info">{{val}}</a>{%else%}<strong>{{val}}</strong>{% endif %}&nbsp; {% endfor
                                %}] {%endif%}{# {%if model|length > 1 %}[ 模型：{%if model_id ==null %}<strong>全部</strong>{%else%}
                                <a
                                href="/admin/article/ad?pid={{pid}}&cate_id={{cate_id}}" class="text-info"> 全部 </a>{%endif%}&nbsp; {% for val in modellist%} {% if model_id != val.id %}<a href="/admin/article/ad?model_id={{val.id}}&pid={{pid}}&cate_id={{cate_id}}"
                                    class="text-info">{{val.title}}</a>{% else %}<strong>{{val.title}}</strong>{% endif %}&nbsp;
                                    {% endfor %} ]{% endif %} 
                                     {% if groups %}[ 分组：{%if group_id ==0 %}<strong style="margin-right: 5px">全部</strong> {%else%} <a href="/admin/article/ad?pid={{pid}}&cate_id={{cate_id}}"  class="text-info" style="margin-right: 5px">全部</a> {%endif%} 
                                    {%for key ,val in groups %} {% if group_id != key %}<a href="/admin/article/ad?pid={{pid}}&cate_id={{cate_id}}&group_id={{key}}&sortid={{sortid}}"  class="text-info">{{val}}</a>{%
                                        else %}<strong>{{val}}</strong>{% endif %}&nbsp; {% endfor %} ]{% endif %} #}
                            </header>
                            <div class="row wrapper">

                                <div class="col-sm-9 m-b-xs">
                                    <div class="">
                                        <div class="btn-group">
                                            <button {%if model|length> 1 %} data-toggle="dropdown" {% endif %} class="btn btn-info btn-sm document_add
                                                dropdown-toggle" {%if model|length
                                                == 1 %} url="/admin/article/add?model_id={{modellist[0].id}}&pid={{pid}}&cate_id={{cate_id}}&group_id={{group_id}}&sortid={{sortid}}"{%endif%}
                                                >添加内容 {%if model|length > 1 %}<span class="caret"></span>{% endif %}</button>
                                            {%if model|length > 1 %}
                                            <ul class="dropdown-menu">

                                                {% for val in modellist%}
                                                <li> <a href="/admin/article/add?model_id={{val.id}}&pid={{pid}}&cate_id={{cate_id}}&group_id={{group_id}}&sortid={{sortid}}"
                                                    class="text-info">添加{{val.title}}</a></li>
                                                {% endfor %}

                                                <!--<li class="divider"></li>-->
                                                <!--<li><a href="#">添加内容</a></li>-->
                                            </ul>
                                            {% endif %}
                                        </div>
                                        <div class="btn-group">
                                            <a class="btn btn-sm btn-info ajax-post" target-form="ids" href="/admin/article/setstatus?status=1" target-form="ids">
                            启用
                        </a>
                                            <a class="btn btn-sm btn-info ajax-post" href="/admin/article/setstatus?status=0" target-form="ids">
                            禁用
                        </a>
                                        </div>

                                        <a class="btn btn-sm btn-info ajax-post confirm" target-form="ids" href="/admin/article/setstatus?status=-1">
                                            删除
                                        </a>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group pull-right search-form">
                                        <input type="text" class="input-sm form-control" name="{{model.search_key|default('title', true)}}" placeholder="请输入关键字"
                                        value="{{controller.get('title')}}">
                                        <span class="input-group-btn">
                        <button class="btn btn-sm btn-default" type="button" id="search" url="/admin/article/index?pid={{pid}}{%if cate_id >0%}&cate_id={{cate_id}}{%endif%}">搜索</button>
                      </span>
                                    </div>
                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped b-t b-light">
                                    <thead>
                                        <tr>
                                            <th style="width:20px;">
                                                <label class="checkbox m-n i-checks">
                                                    <input type="checkbox"><i></i></label>
                                            </th>
                                            {% for field in list_grids %}
                                            <th>{{field.title}}</th>
                                            {% endfor %}
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {% for data in list %}
                                        <tr>
                                            <td>
                                                <label class="checkbox m-n i-checks">
                                                    <input class="ids" type="checkbox" name="ids" value="{{data.id}}"><i></i></label>
                                            </td>
                                            {% for grid in list_grids %}
                                            <td>{{data|get_list_field(grid,ctx.controller)| safe}}</td>
                                            {% endfor %}
                                        </tr>
                                        {% else %}
                                        <tr>
                                            <td colspan="{{list_grids|length + 1}}">
                                                <div class="alert alert-warning alert-block">
                                                    <button data-dismiss="alert" class="close" type="button">×</button>
                                                    <p>暂无数据</p>
                                                </div>
                                            </td>
                                        </tr>

                                        {% endfor %}


                                    </tbody>
                                </table>
                            </div>
                            <footer class="panel-footer">
                                <div class="row">
                                 <div class="col-md-3">
                                 </div>

                                    <div class="col-md-9 text-right text-center-xs">
                                        {{pagerData | safe}}
                                    </div>
                                </div>
                            </footer>
                        </section>
                    </section>
                </section>
            </section>
        </section>
    </section>

</section>


{% endblock %} 
{% block script %}
<script>
        //只有一个模型时，点击新增
        $('.document_add').click(function(){
            var url = $(this).attr('url');
            if(url != undefined && url != ''){
                window.location.href = url;
            }
        });
</script>
{% endblock %} 